package chapter21.section3;

/**
 * Created by lzy
 * Date: 2018/6/4
 */
public class Pair {
    private int x, y;

    public Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public Pair() {
        this(0, 0);
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public void incrementX() {
        x++;
    }

    public void incrementY() {
        y++;
    }

    @Override
    public String toString() {
        return "x:" + x + ", y:" + y;
    }

    public void checkState(){
        if (x != y) {
            throw new PairValuesNotEqualException(this);
        }
    }
}
